import { StyleSheet, Text, View, ScrollView, Image, Pressable } from 'react-native';
import React, { useState, useCallback } from 'react';
import { useNavigation, useRoute, useFocusEffect } from '@react-navigation/native';
import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';
import { ContentStatus, NavBarHeader } from '~/components';
import { onePx, px2dp, scale } from '~/utils/px2dp';
import { getCycleDataApi, getUserLaserDataApi, cycleDataApi, courseLaserListApi } from '~/api/deviceApi';
import { appStore, observer } from '~/store';

const currentDay = new Date();
const day = currentDay.getDate();
const year = currentDay.getFullYear();
const month = currentDay.getMonth() + 1;
const hour = currentDay.getHours();
const minute = currentDay.getMinutes() < 10 ? '0' + currentDay.getMinutes() : currentDay.getMinutes();

export default observer(() => {
    const { t } = useTranslation();
    const navigation = useNavigation<any>();
    const router = useRoute<any>();
    const { type, subDevice_sn, device_code, pupillus_mobile } = router.params || {};
    const [courseImg, setCourseImg] = useState(''); // 疗程icon
    const [userCourse, setUserCourse] = useState({
        course_name: '',
        use_day: 0,
        remaining_days: 0,
        course_id: '',
        id: '',
        en_course_name: '',
    });
    const weeks = [
        t('LaserCycle.t35'),
        t('LaserCycle.t36'),
        t('LaserCycle.t37'),
        t('LaserCycle.t38'),
        t('LaserCycle.t39'),
        t('LaserCycle.t40'),
        t('LaserCycle.t41'),
    ];
    const tip1 = t('LaserCycle.t42');
    const tip3 = t('LaserCycle.t44');
    const errorMessages = [4, 6]; // 定义需要处理的错误代码
    const errorTips = {
        4: tip1,
        6: tip3,
    };
    const [courseInfo, setCourse_info] = useState({ course_cycle_rest_days: 0, course_cycle_work_days: 0 });
    const [isHistory, setIsHistory] = useState(false); // 是否查询历史疗程数据
    const [cycleDate, setCycleDate] = useState(year + '-' + month.toString().padStart(2, '0'));
    const [isRestToday, setIsRestToday] = useState(false); // 判断是否是休息期
    const [isSearch, setIsSearch] = useState(false); // 查询其他日期的
    const [isStartRemark, setIsStartRemark] = useState(''); // 切换的疗程文案
    const [monthList, setMonthList] = useState([]); // 日历
    const [startTimeLong, setStartTimeLong] = useState([]); //激光完成情况
    const [todayChild, setTodayChild] = useState(hour.toString() + minute.toString());
    const [activeIndex, setActiveIndex] = useState(-1); // 选择?号标签
    const [isEpire, setIsEpire] = useState(false); // 疗程状态是否过期
    const [selectDay, setSelectDay] = useState(day);
    const [selectCurrentDay, setSelectCurrentDay] = useState('');
    const [historyData, setHistoryData] = useState([]);
    const [tMonth, setTMonth] = useState<any>(month.toString().padStart(2, '0'));
    // 疗程详情
    const courseDetailes = () => {
        navigation.navigate('MyCourseDetailes', {
            device_sn: subDevice_sn,
            user_course_id: userCourse?.course_id,
            pupillus_mobile,
            type: 1,
        });
    };
    // 获取疗程信息
    const getCycleData = () => {
        getCycleDataApi({ device_sn: subDevice_sn, mobile: pupillus_mobile || '' }).then((res) => {
            if (res.status == 1) {
                setUserCourse(res.user_course);
                setCourse_info(res.course_info);
            } else {
                Toast.show({ content: res.msg });
                setIsEpire(true);
            }
        });
    };
    // 获取当天的激光数据
    const getUserLaserData = () => {
        getUserLaserDataApi({ device_sn: subDevice_sn, mobile: pupillus_mobile || '' }).then((res) => {
            if (res.status == 1) {
                const len = res.parameter.length;
                let start_time_long: any = [];
                for (var i = 0; i < len; i++) {
                    start_time_long.push({
                        start_time: '00:00',
                        start_duration: '0',
                        value: '0',
                        err_code: 0,
                    });
                }
                for (let i = 0; i < len; i++) {
                    start_time_long[i].start_duration = res.parameter[i].start_duration;
                    start_time_long[i].start_time = res.parameter[i].start_time;
                    start_time_long[i].value = 0;
                    start_time_long[i].err_code = 0;
                    let time = res.parameter[i].start_time.split(':');
                    start_time_long[i].hours = time.join('');
                    start_time_long[i].status = parseInt(time.join(''));
                    for (let j = 0; j < res.auto_laser.length; j++) {
                        if (res.parameter[i].start_time == res.auto_laser[j].start_time) {
                            start_time_long[i].value = res.auto_laser[j].time;
                            start_time_long[i].err_code = parseInt(res.auto_laser[j].err_code);
                        }
                    }
                }
                setCourseImg(res.courseImg);
                setStartTimeLong(start_time_long);
            } else {
                Toast.show({ content: res.msg });
            }
        });
    };
    const getWeek = (year: number, month: number): number => {
        // 获取指定年月的第一天是星期几
        return dayjs(`${year}-${month}-01`).day();
    };

    const dateInit = async (setYear?: any, setMonth?: any) => {
        let _dateArr: any = []; // 用于存储日历数据
        let now = setYear && setMonth ? dayjs(`${setYear}-${setMonth}-01`) : dayjs(); // 当前时间或指定时间
        let year = now.year();
        let month = setMonth || now.month() + 1; // 确保使用当前月份
        let dayNums = dayjs(`${year}-${month}`).daysInMonth();
        let startWeek = getWeek(year, month);
        let arrLen = startWeek + dayNums;
        for (let i = 0; i < arrLen; i++) {
            if (i >= startWeek) {
                let day = i - startWeek + 1;
                _dateArr.push({
                    day: day,
                    isSelected: false,
                });
            } else {
                _dateArr.push({});
            }
        }
        const paramsDay = `${year}-${month}`;
        setCycleDate(paramsDay); // 假设是外部函数
        await cycleData(_dateArr, paramsDay); // 假设是外部异步函数
    };

    // 获取日历
    const cycleData = (dataList = [], time?: string) => {
        cycleDataApi({
            device_sn: subDevice_sn,
            mobile: pupillus_mobile || '',
            date: time,
        })
            .then((res) => {
                if (res.code === 200 && res.data.days.length > 0) {
                    let cycleList = res.data.days || [];
                    const formattedDate = dayjs().format('YYYY-MM-DD');
                    const currentTimestamp = Date.parse(formattedDate);
                    const updatedDataList: any = dataList.map((_element: any) => {
                        if (_element.day) {
                            const day = String(_element.day).padStart(2, '0'); // 确保格式为两位数
                            const matchingElement = cycleList.find((element) => {
                                const elementDay = element.date.slice(-2); // 取出日期的最后两位数字
                                return day === elementDay; // 匹配日字段
                            });
                            let dayTime: any = new Date(matchingElement.date).getTime().toString();
                            if (currentTimestamp == dayTime && matchingElement.type == 2) {
                                setIsRestToday(true);
                            }
                            if (matchingElement) {
                                if (currentTimestamp == dayTime && matchingElement.start_type == 1) {
                                    setIsStartRemark(
                                        `${t('LaserCycle.t47')}${matchingElement.change_time}${t('LaserCycle.t48')}`,
                                    );
                                }
                                return {
                                    ..._element,
                                    date: matchingElement.date,
                                    course_id: matchingElement.course_id,
                                    change_time: matchingElement.change_time || '',
                                    jobs:
                                        matchingElement.type === 2
                                            ? 'noSelect'
                                            : matchingElement.type === 3
                                            ? 'select'
                                            : '',
                                    complete: matchingElement.status === 1 ? 'complete' : '',
                                    start: matchingElement.start_type === 1 ? 'start' : '',
                                };
                            }
                        }
                        return _element;
                    });
                    setMonthList(updatedDataList);
                } else {
                    Toast.show({ content: res.msg });
                }
            })
            .catch((err) => {
                console.log('erererer', err);
            });
    };
    // 查看对应的errcode的文案
    const checkErrcode = (index) => {
        const currentActiveIndex = activeIndex;
        setActiveIndex(currentActiveIndex == index ? null : index);
    };
    const isAfterToday = (dateString) => {
        const givenDate = new Date(dateString);
        const today = new Date();
        givenDate.setHours(0, 0, 0, 0);
        today.setHours(0, 0, 0, 0);
        return givenDate > today;
    };
    // 搜索历史
    const searchDate = (res) => {
        const { course_id, date, day, isSelected, jobs, start, change_time } = res;
        if (isEpire && isAfterToday(date)) {
            Toast.show({ content: t('LaserCycle.t45') });
            return;
        }
        setActiveIndex(-1);
        monthList.forEach((ele: any) => {
            if (ele.date == date) {
                if (ele.jobs == 'select') {
                    setIsSearch(true);
                    setSelectCurrentDay(date);
                    setSelectDay(ele.day);
                    const today = `${new Date().getFullYear()}-${(new Date().getMonth() + 1)
                        .toString()
                        .padStart(2, '0')}-${new Date().getDate().toString().padStart(2, '0')}`;
                    if (date !== today) {
                        // 假如不是当天查询历史激光接口
                        getCourseLaserList(date, course_id);
                    } else {
                        // 假如当天过期疗程过期啦
                        if (isEpire) {
                            getCourseLaserList(date, course_id);
                        } else {
                            setIsHistory(false);
                            setIsSearch(false);
                            setSelectCurrentDay('');
                            setIsRestToday(false);
                            getUserLaserData();
                            getCycleData();
                        }
                    }
                } else {
                    Toast.show({ content: date + t('LaserCycle.t46') });
                }
            }
        });
        if (start == 'start') {
            setIsStartRemark(`${t('LaserCycle.t51')}${change_time}${t('LaserCycle.t52')}`);
        } else {
            setIsStartRemark('');
        }
    };
    // 查询历史激光数据
    const getCourseLaserList = (date, course_id) => {
        courseLaserListApi({
            device_sn: subDevice_sn,
            mobile: pupillus_mobile || '',
            date,
            course_id,
        }).then((res) => {
            const {
                course_cycle_rest_days,
                course_cycle_work_days,
                laser_list,
                course_name,
                remaining_days,
                course_id,
                en_course_name,
            } = res.data;
            setCourse_info({
                course_cycle_rest_days,
                course_cycle_work_days,
            });
            setIsHistory(true);
            setIsRestToday(false);
            const updatedData = laser_list.map((item) => ({
                ...item,
                err_code: parseInt(item.err_code, 10),
            }));
            setHistoryData(updatedData);
            setUserCourse({
                course_name: course_name,
                id: '',
                remaining_days: remaining_days,
                course_id: course_id,
                use_day: 0,
                en_course_name,
            });
        });
    };

    const getYearAndMonth = (str) => {
        const year = dayjs(str).year(); // 获取年份
        const month = dayjs(str).month() + 1;
        return { year, month };
    };
    // 查询上月或者更早历史月份数据
    const switchData = (type) => {
        const currentYear = dayjs().year(); // 获取当前年份
        const currentMonth = dayjs().month() + 1; // 获取当前月份（0 表示1月，需要 +1）
        const currentTime = currentYear + '-' + currentMonth.toString().padStart(2, '0');
        if (type == 2) {
            if (currentTime == cycleDate) {
                Toast.show({ content: t('LaserCycle.t49') });
                return;
            } else {
                const nextMonth = dayjs(cycleDate).add(1, 'month').format('YYYY-MM');
                const { year, month } = getYearAndMonth(nextMonth);
                dateInit(year.toString(), month.toString());
                setTMonth(month.toString());
            }
        } else {
            const lastMonth = dayjs(cycleDate).subtract(1, 'month').format('YYYY-MM');
            const { year, month } = getYearAndMonth(lastMonth);
            dateInit(year.toString(), month.toString());
            setTMonth(month.toString());
        }
    };
    useFocusEffect(
        useCallback(() => {
            dateInit();
            getCycleData();
            getUserLaserData();
        }, []),
    );
    return (
        <View style={styles.container}>
            <NavBarHeader title={t('LaserCycle.title')} />
            <ScrollView showsVerticalScrollIndicator={false} contentContainerStyle={styles.contentContainerStyle}>
                <View style={styles.card}>
                    <Text>{t('LaserCycle.t1')} </Text>
                    <View style={styles.line}></View>
                    <View style={[styles.row, styles.between]}>
                        <View style={styles.row}>
                            <Image
                                style={styles.course_icons}
                                source={{
                                    uri:
                                        courseImg ||
                                        'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/already.png',
                                }}
                            />
                            <View>
                                <Text style={styles.courseTitle}>
                                    {appStore.app.language == 'zh'
                                        ? userCourse?.course_name
                                        : userCourse?.en_course_name
                                        ? userCourse?.en_course_name
                                        : userCourse?.course_name}
                                </Text>
                                {isHistory ? (
                                    <Text style={styles.day}>
                                        {t('LaserCycle.t2')}:{userCourse?.remaining_days} {t('LaserCycle.t3')}
                                    </Text>
                                ) : (
                                    <Text style={styles.day}>
                                        {t('LaserCycle.t4')}:{userCourse?.use_day}
                                        {t('LaserCycle.t3')}
                                    </Text>
                                )}
                            </View>
                        </View>
                        <Pressable style={styles.course_detailes} onPress={courseDetailes}>
                            <Text style={styles.detailes_title}>{t('LaserCycle.t5')}</Text>
                        </Pressable>
                    </View>
                </View>
                <View style={styles.card}>
                    <View style={[styles.row, styles.between]}>
                        <Text>{t('LaserCycle.t6')}</Text>
                        <View style={styles.row}>
                            <Pressable onPress={() => switchData(1)}>
                                <Image
                                    style={styles.icons}
                                    source={{
                                        uri: 'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/dataUp.png',
                                    }}
                                />
                            </Pressable>
                            <Text style={styles.date}>{cycleDate}</Text>
                            <Pressable onPress={() => switchData(2)}>
                                <Image
                                    style={styles.icons}
                                    source={{
                                        uri: 'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/dataDown.png',
                                    }}
                                />
                            </Pressable>
                        </View>
                    </View>
                    <View style={[styles.row, styles.between]}>
                        {weeks.map((item, index) => {
                            return (
                                <View key={index} style={styles.listWeek}>
                                    <Text style={styles.week}>{item}</Text>
                                </View>
                            );
                        })}
                    </View>
                    <View style={[styles.row, styles.warp]}>
                        {monthList.map((item: any, index) => {
                            return (
                                <Pressable key={index} style={[styles.listDay]} onPress={() => searchDate(item)}>
                                    <Text style={selectDay == item.day && month == tMonth && styles.istoDay}>
                                        {item.day}
                                    </Text>
                                    {/* 工作期 */}
                                    {item.jobs == 'select' && <View style={styles.select}></View>}
                                    {/* 休息期 */}
                                    {item.jobs == 'noSelect' && (
                                        <View style={[styles.select, { backgroundColor: '#F19F43' }]}></View>
                                    )}
                                    {/* 疗程切换 */}
                                    {item.start == 'start' && (
                                        <View style={[styles.select, { backgroundColor: '#009933' }]}></View>
                                    )}
                                    {/* 疗程完成 */}
                                    {item.complete == 'complete' && item.jobs == 'select' && (
                                        <Image
                                            style={styles.tick}
                                            source={{
                                                uri: 'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/complete.png',
                                            }}
                                        />
                                    )}
                                </Pressable>
                            );
                        })}
                    </View>
                    <View style={[styles.between]}>
                        <View style={[styles.row, { marginTop: px2dp(12) }]}>
                            <View style={[styles.select]}></View>
                            <Text style={styles.t1}>
                                {t('LaserCycle.t7')}：{t('LaserCycle.t8')}
                                {courseInfo?.course_cycle_work_days}
                                {t('LaserCycle.t9')}
                            </Text>
                        </View>
                        <View style={[styles.row, { marginTop: px2dp(12) }]}>
                            <View style={[styles.select, { backgroundColor: '#F19F43' }]}></View>
                            <Text style={styles.t1}>
                                {t('LaserCycle.t10')}： {t('LaserCycle.t8')}
                                {courseInfo?.course_cycle_rest_days} {t('LaserCycle.t11')}
                            </Text>
                        </View>
                    </View>
                    <View style={[styles.row, { marginTop: px2dp(12) }]}>
                        <View style={[styles.select, { backgroundColor: '#009933' }]}></View>
                        <Text style={styles.t1}>{t('LaserCycle.t12')}</Text>
                    </View>
                    {isStartRemark && <Text style={styles.startRemark}>{isStartRemark}</Text>}
                    <View style={[styles.row, { marginTop: px2dp(12) }]}>
                        <Image
                            style={styles.tick}
                            source={{
                                uri: 'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/complete.png',
                            }}
                        />
                        <Text style={styles.t1}>{t('LaserCycle.t13')}</Text>
                    </View>
                    <View style={[styles.row, { marginTop: px2dp(12) }]}>
                        <Image
                            style={styles.icon1}
                            source={{
                                uri: 'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/phiz.png',
                            }}
                        />
                        <Text style={styles.t1}>
                            {t('LaserCycle.t14')}
                            {(
                                parseInt(courseInfo?.course_cycle_work_days.toString()) +
                                parseInt(courseInfo?.course_cycle_rest_days.toString())
                            ).toString()}
                            {t('LaserCycle.t15')}
                            {courseInfo?.course_cycle_work_days} {t('LaserCycle.t16')}，
                            {courseInfo?.course_cycle_rest_days}
                            {t('LaserCycle.t17')}
                        </Text>
                    </View>
                </View>
                {/* 今日激光 */}
                <View style={styles.card}>
                    <Text>
                        {isRestToday
                            ? t('LaserCycle.t18')
                            : selectCurrentDay
                            ? selectCurrentDay + t('LaserCycle.t19')
                            : t('LaserCycle.t20')}
                    </Text>
                    <View style={styles.line} />
                    {!isRestToday && !isSearch && (
                        <View>
                            {startTimeLong.map((item: any, index) => {
                                return (
                                    <View key={index} style={[styles.list_time]}>
                                        <View style={[styles.row, styles.between]}>
                                            <View style={styles.row}>
                                                <Text>{item.start_time}</Text>
                                                {appStore.app.language == 'zh' ? (
                                                    <Text style={styles.duration}>
                                                        （治疗{item.start_duration}分钟）
                                                    </Text>
                                                ) : (
                                                    <Text style={styles.duration}>（{item.start_duration}Mine）</Text>
                                                )}

                                                {/* 4充电关闭文案、 6手动关闭 --完成*/}
                                                {item.value >= 2 && errorMessages.includes(item.err_code) && (
                                                    <Pressable style={[styles.row]} onPress={() => checkErrcode(index)}>
                                                        <Image
                                                            style={styles.issue}
                                                            source={require('~/assets/user/issue.png')}
                                                        />
                                                    </Pressable>
                                                )}
                                            </View>
                                            {item.value >= 2 && (
                                                <View style={styles.row}>
                                                    <Text>{t('LaserCycle.t28')}</Text>
                                                    <Image
                                                        style={styles.icons2}
                                                        source={{
                                                            uri: 'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/select.png',
                                                        }}
                                                    />
                                                </View>
                                            )}
                                            {item.value < 2 && item.status < todayChild && (
                                                <View style={styles.row}>
                                                    <Text>{t('LaserCycle.t29')}</Text>
                                                    <Image
                                                        style={styles.icons2}
                                                        source={{
                                                            uri: 'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/not.png',
                                                        }}
                                                    />
                                                </View>
                                            )}
                                            {item.value < item.start_duration && item.status > todayChild && (
                                                <View style={styles.row}>
                                                    <Text>{t('LaserCycle.t30')}</Text>
                                                    <Image
                                                        style={styles.icons2}
                                                        source={{
                                                            uri: 'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/tobe.png',
                                                        }}
                                                    />
                                                </View>
                                            )}
                                        </View>
                                        <View style={{ marginVertical: px2dp(12) }}>
                                            {item.err_code !== 0 && (
                                                <Text style={styles.err_code}>
                                                    {item.err_code == 1
                                                        ? t('LaserCycle.t21')
                                                        : item.err_code == 2
                                                        ? t('LaserCycle.t22')
                                                        : item.err_code == 3
                                                        ? t('LaserCycle.t23')
                                                        : item.err_code == 4
                                                        ? t('LaserCycle.t24')
                                                        : item.err_code == 5
                                                        ? t('LaserCycle.t25')
                                                        : item.err_code == 6
                                                        ? t('LaserCycle.t26')
                                                        : item.err_code == 7
                                                        ? t('LaserCycle.t27')
                                                        : item.err_code == 8
                                                        ? t('LaserCycle.t50')
                                                        : ''}
                                                </Text>
                                            )}
                                        </View>
                                        {activeIndex == index && item.value >= 2 && errorTips[item.err_code] && (
                                            <Text style={styles.tips}>{errorTips[item.err_code]}</Text>
                                        )}
                                    </View>
                                );
                            })}
                        </View>
                    )}
                    {historyData.length > 0 && !isRestToday && isSearch && (
                        <View>
                            {historyData.map((item: any, index) => {
                                return (
                                    <View key={index} style={[styles.list_time]}>
                                        <View style={[styles.row, styles.between]}>
                                            <View style={styles.row}>
                                                <Text>{item.time}</Text>
                                                <Text style={styles.duration}>
                                                    （{t('LaserCycle.t32')}
                                                    {item.interval}
                                                    {t('LaserCycle.t33')}）
                                                </Text>

                                                {/* 4充电关闭文案、 5脱腕关闭文案、6手动关闭 --完成*/}
                                                {item.type == 1 && errorMessages.includes(item.err_code) && (
                                                    <Pressable style={[styles.row]} onPress={() => checkErrcode(index)}>
                                                        <Image
                                                            style={styles.issue}
                                                            source={require('~/assets/user/issue.png')}
                                                        />
                                                    </Pressable>
                                                )}
                                            </View>
                                            {item.type == 1 && item.err_code !== 8 && (
                                                <View style={styles.row}>
                                                    <Text>{t('LaserCycle.t28')}</Text>
                                                    <Image
                                                        style={styles.icons2}
                                                        source={{
                                                            uri: 'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/select.png',
                                                        }}
                                                    />
                                                </View>
                                            )}
                                            {(item.type == 2 || item.err_code == 8) && (
                                                <View style={styles.row}>
                                                    <Text>{t('LaserCycle.t29')}</Text>
                                                    <Image
                                                        style={styles.icons2}
                                                        source={{
                                                            uri: 'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/not.png',
                                                        }}
                                                    />
                                                </View>
                                            )}
                                            {item.type == 3 && (
                                                <View style={styles.row}>
                                                    <Text>{t('LaserCycle.t30')}</Text>
                                                    <Image
                                                        style={styles.icons2}
                                                        source={{
                                                            uri: 'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/tobe.png',
                                                        }}
                                                    />
                                                </View>
                                            )}
                                        </View>
                                        <View style={{ marginVertical: px2dp(12) }}>
                                            {item.err_code !== 0 && (
                                                <Text style={styles.err_code}>
                                                    {item.err_code == 1
                                                        ? t('LaserCycle.t21')
                                                        : item.err_code == 2
                                                        ? t('LaserCycle.t22')
                                                        : item.err_code == 3
                                                        ? t('LaserCycle.t23')
                                                        : item.err_code == 4
                                                        ? t('LaserCycle.t24')
                                                        : item.err_code == 6
                                                        ? t('LaserCycle.t26')
                                                        : item.err_code == 7
                                                        ? t('LaserCycle.t27')
                                                        : item.err_code == 8
                                                        ? t('LaserCycle.t50')
                                                        : ''}
                                                </Text>
                                            )}
                                        </View>
                                        {activeIndex == index && item.type == 1 && errorTips[item.err_code] && (
                                            <Text style={styles.tips}>{errorTips[item.err_code]}</Text>
                                        )}
                                    </View>
                                );
                            })}
                        </View>
                    )}
                    {isRestToday && (
                        <ContentStatus
                            status="empty"
                            source={{
                                image: { uri: 'https://bjy-dev.oss-cn-shenzhen.aliyuncs.com/xcx/images/rest.png' },
                                title: t('LaserCycle.t34'),
                            }}
                        />
                    )}
                </View>
            </ScrollView>
        </View>
    );
});

const styles = StyleSheet.create({
    warp: {
        flexWrap: 'wrap',
    },
    row: {
        flexDirection: 'row',
        alignItems: 'center',
    },
    between: {
        justifyContent: 'space-between',
    },
    container: {
        flex: 1,
    },
    contentContainerStyle: {
        flexGrow: 1,
        paddingBottom: '20%',
        marginHorizontal: px2dp(12),
        marginTop: px2dp(32),
    },
    card: {
        backgroundColor: '#fff',
        padding: px2dp(24),
        borderRadius: px2dp(16),
        marginBottom: px2dp(32),
    },
    line: {
        width: '100%',
        height: px2dp(2),
        backgroundColor: '#eee',
        marginVertical: px2dp(32),
    },
    course_icons: {
        width: px2dp(60),
        height: px2dp(60),
        marginRight: px2dp(24),
    },
    courseTitle: {
        fontSize: scale(28),
        fontWeight: 'bold',
    },
    day: {
        color: '#a4a4a4',
        marginTop: px2dp(12),
    },
    course_detailes: {
        width: px2dp(140),
        height: px2dp(60),
        borderRadius: px2dp(30),
        backgroundColor: '#1877FF',
        justifyContent: 'center',
        alignItems: 'center',
    },
    detailes_title: {
        color: '#fff',
        fontSize: scale(24),
    },
    icons: {
        width: px2dp(28),
        height: px2dp(28),
    },
    date: {
        marginHorizontal: px2dp(12),
        fontSize: scale(30),
    },
    listWeek: {
        justifyContent: 'center',
        alignItems: 'center',
        width: px2dp(90),
        marginTop: px2dp(32),
    },
    week: {
        fontSize: scale(28),
        color: '#000',
        fontWeight: 'bold',
    },
    listDay: {
        justifyContent: 'center',
        alignItems: 'center',
        width: '13%',
        borderBottomWidth: onePx,
        borderColor: '#eee',
        height: px2dp(120),
        marginLeft: px2dp(6),
    },
    istoDay: {
        backgroundColor: '#1877FF',
        color: '#fff',
        padding: px2dp(4),
        borderRadius: px2dp(24),
        width: px2dp(80),
        textAlign: 'center',
    },
    select: {
        backgroundColor: '#6C93F6',
        width: px2dp(10),
        height: px2dp(10),
        borderRadius: px2dp(5),
        marginTop: px2dp(10),
    },
    tick: {
        width: px2dp(28),
        height: px2dp(18),
        resizeMode: 'stretch',
    },
    t1: {
        color: '#a4a4a4',
        fontSize: scale(26),
        marginLeft: px2dp(6),
    },
    icon1: {
        width: px2dp(30),
        height: px2dp(30),
    },
    startRemark: {
        color: 'red',
        fontSize: scale(24),
        marginVertical: px2dp(12),
        fontWeight: 'bold',
        lineHeight: px2dp(38),
    },
    list_time: {
        marginBottom: px2dp(32),
    },
    duration: {
        color: '#88D0C5',
        fontWeight: 'bold',
        marginLeft: px2dp(12),
    },
    err_code: {
        color: 'red',
        fontWeight: 'bold',
        marginLeft: px2dp(16),
        fontSize: scale(26),
    },
    icons2: {
        width: px2dp(30),
        height: px2dp(30),
        marginLeft: px2dp(12),
    },
    issue: {
        width: px2dp(34),
        height: px2dp(34),
        marginLeft: px2dp(12),
    },
    tips: {
        color: '#a4a4a4',
        fontSize: scale(26),
        marginTop: px2dp(12),
        lineHeight: px2dp(40),
    },
});
